<%--
SYSTEM NAME 	: 기술적보호조치표준서비스
PROGRAM ID 		: pesResult
PROGRAM NAME 	: 성능평가신청
AUTHOR 			: 강평희
CREAT DATE 		: 2010-09-17
MODIFY DATE		: 
DESCRIPTION 	: 성능평가신청목록
--%>
<%@ page language="java"
	import="java.sql.*,javax.sql.*,java.util.*,java.io.*,javax.naming.*"
	pageEncoding="UTF-8"%>
<%@ page import="com.markany.beans.util.*"%>
<%@ page import="com.markany.beans.property.*"%>
<%@ page import="com.markany.beans.src.MasterDao"%>
<%@ page import="org.apache.log4j.Logger"%>
<%@page import="com.dmail.beans.src.DmailDao"%>
<%@page import="com.oreilly.servlet.Base64EnTAB_CODEr"%>
<%! private Logger logger = Logger.getLogger(this.getClass().getName()); %>
<%
	//서버패스 잡기
	String ctxPath = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + ctxPath + "/ctis_mng";
	
	String PAGE = "pesResult";
	String DIR = "performance";
	String PAGE_NAME = "성능평가 신청 현황";
	String NAV = "Home > 표준서비스  > 성능평가 신청 현황";
%>
<%@ include file="/jsp/common/ctis_sessinc.jsp" %>
<jsp:useBean id="bean" class="com.markany.beans.util.PageBean" scope="page" />
<jsp:setProperty name="bean" property="*" />
<jsp:setProperty name="bean" property="intPageLine" value="10" />
<%
	String sql = "";
	String searchSqltx = "";
	String searchSqltxTech = "";
	String sqlTestGb = "";
	int totalCnt = 0;
	
	String searchTx = hp.getString("searchTx","");
	String searchTechNm = hp.getString("searchTechNm","");
	String testGb = hp.getString("testGb","");
	
	MasterDao dao = null;
	Vector list = null;

	try{
		dao = new MasterDao();

		if( !searchTx.equals("") )
		{
			searchSqltx = " AND BIZ_NM LIKE '%' || '"+searchTx+"' || '%' ";
		}
		
		if( !searchTechNm.equals("") )
		{
			searchSqltxTech = " AND TECH_NM LIKE '%' || '"+searchTechNm+"' || '%' ";
		}
		
		if( !testGb.equals("") ){
			
			sqlTestGb = " AND TEST_GB ='"+ testGb +"'";
		}
		
//		sql = PassBundle_copyright.getString("SELECT_TAB_TEST_1_CNT");
		sql += "SELECT COUNT(P.RECEIPT_NO) FROM TAB_TEST_1 P, TAB_CODE C WHERE 1=1 AND P.LAST_PROC_STATUS = C.CD ";
		if( !searchSqltx.equals("") ) sql += " "+ searchSqltx +" \n";
		if( !searchSqltxTech.equals("") ) sql += " "+ searchSqltxTech +" \n";
		if( !sqlTestGb.equals("") ) sql += " "+ sqlTestGb +" \n";
		
		dao.setCommand(sql);
		
		totalCnt = dao.getTotalRowNoClose();
		
		dao.close();
		
		dao = new MasterDao();
		
		bean.setIntTotalRow(totalCnt);
		
		sql = "";
		sql = PassBundle_copyright.getString("SELECT_TAB_TEST_1_LIST");
		/*
		SELECT_TAB_TEST_1_LIST = SELECT * \n
		FROM ( \nSELECT RESULT_TABLE.* \n
				FROM ( \nSELECT LIST_TABLE.* ,  ROWNUM RNO \n
						FROM ( \nSELECT P.RECEIPT_NO, P.BIZ_NM , TO_CHAR(P.RECEIPT_DATE,'YYYY-MM-DD HH24\:MI') AS RECEIPT_DATE, 
								P.LAST_PROC_STATUS, P.PROGRAM_NM, C.CD_NM, P.TECH_NM, P.TEST_GB  \n
								FROM TAB_TEST_1 P , TAB_CODE C  \n
								WHERE 1\=1 AND P.LAST_PROC_STATUS \= C.CD $SEARCH_CONDITION1$ $SEARCH_CONDITION2$ $SEARCH_CONDITION3$ 
								ORDER BY RECEIPT_NO DESC \n
								) LIST_TABLE \n
								) RESULT_TABLE WHERE RNO<\= ? \n
								) LIST WHERE RNO BETWEEN ? AND ?
								 
		*/
		sql = Utils.replaceStr(sql, "$SEARCH_CONDITION1$", searchSqltx.toString());
		sql = Utils.replaceStr(sql, "$SEARCH_CONDITION2$", searchSqltxTech.toString());
		sql = Utils.replaceStr(sql, "$SEARCH_CONDITION3$", sqlTestGb.toString());
		
		dao.setCommand(sql);

		int arg = 1; 
		dao.setInt(arg++, (bean.getIntCurrentPage() * bean.getIntPageLine()));
		dao.setInt(arg++, (bean.getIntCurrentPage() - 1) * bean.getIntPageLine() + 1);
		dao.setInt(arg++, (bean.getIntCurrentPage() * bean.getIntPageLine()));		
		
		list = dao.getResultHashtableNoClose();
		
//		dao.close();
		
	} catch (Exception e) {
		logger.error(PAGE + " Exception e.toString()      : " + e.toString());
		logger.error(PAGE + " Exception e.getMessage()    : " + e.getMessage());
		logger.error(PAGE + " Exception strQuery  : \n" + sql);
	%>
	<SCRIPT LANGUAGE="JavaScript">
	<!--
		alert(' [<%=PAGE%>] : <%=e.toString().replace("\n","")%>')
	//-->
	</SCRIPT>
	<%
	} finally {
		dao.close();
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> 기술적보호조치 표준 서비스 :: </title>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<META http-equiv="cache-control" content="no-cache, must-revalidate" />
<META http-equiv="pragma" content="no-cache" />
<link rel="stylesheet" type="text/css" href="../css/common.css" />
<link rel="stylesheet" type="text/css" href="../css/contents.css" />
<link rel="stylesheet" type="text/css" href="../css/new.css" />

<script type="text/javascript" src="../js/gnb.js"></script>
<script language="JavaScript" src="../js/common.js" ></script>
<script type="text/javascript" src="../js/popupcalendar.js"></script>
<script type="text/javascript" src="../js/script.js"></script>
<script type="text/javascript" src="../js/ComUtil.js"></script>

<SCRIPT LANGUAGE="JavaScript">
<!--
	var f = document.all;
	
	function Page(page,t) {
		form.intCurrentPage.value = page;
		form.testGb.value = t;
		form.action = "pesResult.jsp";
		form.submit();
	}

	function search() {
		form.intCurrentPage.value = 1;
		form.action = "pesResult.jsp";
		form.submit();
	}

	function view( cid ){
		var frm = document.form;

		frm.cid.value = cid;
		frm.action = "metaLogD.jsp";
		frm.submit();
	}
	
		function excel(  ){
 	  	var frm = document.excelForm;
 	  	var sfrm = document.form;
 	  	var exc = document.getElementById("excel");

 	  	frm.sdate.value = sfrm.SREG_DATE.value;
 	  	frm.edate.value = sfrm.EREG_DATE.value;

 		frm.action = "mailListExcel.jsp";
 		frm.target = "excel";
 		frm.submit();
 	}

	function goDetail(val,proc,tgb){
		
		var frm = document.detailForm;
		frm.RECEIPTNO.value = val;
		frm.LASTPROCSTAT.value = proc;
		frm.TESTGB.value = tgb;
//		location.href = "pesForm.jsp?receiptNO="+val+"&lastprocstat="+proc;
		frm.action = "pesForm.jsp";
		frm.submit();
		
	}
	
	  
//-->
</SCRIPT>
</head>
<body>
<form method="post" name="detailForm">
	<input type="hidden" name="RECEIPTNO" value=""/>
	<input type="hidden" name="LASTPROCSTAT" value=""/>
	<input type="hidden" name="TESTGB" value=""/>
</form>
<form METHOD="POST" NAME="form">
<input type="hidden" name="intCurrentPage" value="<%=bean.getIntCurrentPage()%>"/>
<input type="hidden" name="testGb" value="<%=testGb %>"/>
<%@ include file="/ctis_mng/common/menu.jsp" %>
	<div id="contents" >
<%--		<div class="searchBox" >--%>
			<table class="checkTable last">
				<tr>
						<th width="100" class="center">신청인</th>
						<td class="p10">
							<input type="text" class="w195" name="searchTechNm" value="<%=searchTechNm%>" />
						</td>
						<th width="100" class="center">신청 업체명</th>
						<td class="p10">
							<input type="text" class="w195" name="searchTx" value="<%=searchTx%>" onkeypress="javascript:if(event.keyTAB_CODE == 13) return search();"/>
						</td>
						
				</tr>		
			</table>

			<div class="buttonC">
				<a href="javascript:search();" onfocus="this.blur();"><img src="../images/btn_apply.gif" width="55" height="25" alt="조회" align="absmiddle" /></a>
        	</div>
        <div class="dashLine"></div>
        <h3>
        	<img src="../images/title_searchMusicCon.gif" width="67" height="15" alt="검색결과" />
        </h3>
		<p id="searchWord" class="main_text_1">
			<span class="word"><%=totalCnt%> 건</span>이 검색되었습니다.
		</p>
        <table class="bgTable2">
        	<tr>
				<th width="40">순번</th>
				<th width="100"><p><span>|</span>신청인</p></th>
				<th width="100"><p><span>|</span>접수번호</p></th>
				<th width=""><p><span>|</span>업체명</p></th>
				<th width="100"><p><span>|</span>신청일자</p></th>
				<th width="150"><p><span>|</span>프로그램명</p></th>
				<th width="80"><p><span>|</span>처리상태</p></th>
			</tr>
				<%
					if(list.size()>0){
						String no = "";
						String rcptNo = "";
						String bizNM = "";
						String rcptDate = "";
						String requestTYP = "";
						String programNM = "";
						String cdNM = "";
						String techNM = "";
					    
					    int bno = 0;
					    int CNum = bean.getIntCurrentPage() ;
					    
					    
					    String dmlSql = "";
					    
						for (int i=0 ;i<list.size();i++){
							bno = (totalCnt- (CNum-1)*10) - i;					
						
							rcptNo		= ((Hashtable) list.elementAt(i)).get("RECEIPT_NO")+"";
							no			= ((Hashtable) list.elementAt(i)).get("RNO")+"";
							bizNM		= ((Hashtable) list.elementAt(i)).get("BIZ_NM")+"";
							rcptDate	= ((Hashtable) list.elementAt(i)).get("RECEIPT_DATE")+"";  
							requestTYP	= ((Hashtable) list.elementAt(i)).get("LAST_PROC_STATUS")+""; 
							programNM	= ((Hashtable) list.elementAt(i)).get("PROGRAM_NM")+"";  
							cdNM		= ((Hashtable) list.elementAt(i)).get("CD_NM")+"";
							techNM		= ((Hashtable) list.elementAt(i)).get("TECH_NM")+"";
						
					%>
			<tr>
				<td>
					<%=bno%>
				</td>
				<td>
					<a href="javascript:goDetail('<%=rcptNo%>','<%=requestTYP%>','<%=testGb %>');" ><%=techNM%></a>
				</td>
				<td>
					<a href="javascript:goDetail('<%=rcptNo%>','<%=requestTYP%>','<%=testGb %>');" ><%=rcptNo%></a>
				</td>
				<td>
					<a href="javascript:goDetail('<%=rcptNo%>','<%=requestTYP%>','<%=testGb %>');" ><%=bizNM%></a>
				</td>
				<td><%=rcptDate%></td>
				<td><%=programNM%></td>
				<td><%=cdNM%></td>
			</tr>
<%
	}
} else {
%>	

			<tr>
				<td colspan="7">데이터가 없습니다.</td>
			</tr>
<%	
}
%>
		</table>
<div class="paging">
<% 
if(list.size()>0){ 
	int iTemp=0;
	int intCurrentPage  = bean.getIntCurrentPage() ;
	int intTotalPage    = bean.getIntTotalPage() ;
	int intPageNum      = bean.getIntPageNum() ;

	int intStartPage    = ((int)Math.ceil((double)intCurrentPage/(double)intPageNum) -1 ) * intPageNum +1 ;
%>
	<% if (intStartPage>10) { %>
		<a href="JavaScript:Page('<%= intStartPage-intPageNum %>','<%=testGb %>')"><img src="../images/common/page_llArrow.gif" width="11" height="11" alt="맨 앞으로" /></a>&nbsp;
	<%	}else{	%>
		<img src="../images/common/page_llArrow.gif" width="11" height="11" alt="맨 앞으로" />&nbsp;
	<%  }  %>

	<% if (intCurrentPage>1) { %>
		<a href="JavaScript:Page('<%= intCurrentPage-1 %>','<%=testGb %>')"><img src="../images/common/page_lArrow.gif" width="11" height="11" alt="이전" /></a>&nbsp;
	<%	}else{	%>
		<img src="../images/common/page_lArrow.gif" width="11" height="11" alt="이전" />&nbsp;
	<%  }  %>

	<% 
	  for (int i=intStartPage; i<intStartPage + intPageNum ; i++) { 
		iTemp=i;
		if (i<=intTotalPage) {
			if (i !=intCurrentPage) {
	%>
		<a href="JavaScript:Page('<%= i %>','<%=testGb %>')"><%= i %></a><%=(i<intTotalPage)?"<span>|</span>":""%>
	<%		} else {	%>
		<span class="current"><%= i %></span><%=(i<intTotalPage)?"<span>|</span>":""%>
	<%		}	
		} else	{
			break;
		}	
 	  }
	%>
	<%	if (intCurrentPage < intTotalPage) { %>
		&nbsp;<a href="JavaScript:Page('<%= intCurrentPage+1 %>','<%=testGb %>')"><img src="../images/common/page_rArrow.gif" width="11" height="11" alt="다음" /></a>
	<%	}else{	%>
		&nbsp;<img src="../images/common/page_rArrow.gif" width="11" height="11" alt="다음" />
	<%  }	%>
	
	<%	if (iTemp+1<= intTotalPage) { %>
		&nbsp;<a href="JavaScript:Page('<%= iTemp+1 %>','<%=testGb %>')"><img src="../images/common/page_rrArrow.gif" width="11" height="11" alt="맨 뒤로" /></a>
	<%	}else{	%>
		&nbsp;<img src="../images/common/page_rrArrow.gif" width="11" height="11" alt="맨 뒤로" />
	<%  }	%>
<%}%>

</div>	
</div>	
		<!-- //right -->
	<!-- //content -->

	<!-- footer -->
	<div id="footer">
		<img src="../images/common/copyright.gif" width="253" height="12" alt="" />
	</div>
	<!-- //footer -->
	</form>
		<iframe name="excel" width="0" height="0" frameborder="0"></iframe>

  </body>
</html>